@*+:cnd:noEmit*@
@attribute [Route(PageUrls.Home)]
@attribute [Route("{culture:nonfile?}" + PageUrls.Home)]
@attribute [AppResponseCache(SharedMaxAge = 3600 * 24, MaxAge = 60 * 5)]
@inherits AppPageBase

<AppPageData Title="@Localizer[nameof(AppStrings.Home)]"
             PageTitle="@Localizer[nameof(AppStrings.HomePageTitle)]" />

<section>
    <BitStack Alignment="BitAlignment.Center" Gap="2rem" Class="root-stack">
        <BitText Typography="BitTypography.H4" Align="BitTextAlign.Center">
            @Localizer[nameof(AppStrings.HomePanelTitle)]
            <br />
            @Localizer[nameof(AppStrings.HomePanelSubtitle)]
        </BitText>

        <BitText Typography="BitTypography.H6" Align="BitTextAlign.Center">
            @Localizer[nameof(AppStrings.HomeMessage)]
        </BitText>

        @*#if (module == "Sales")*@
        <BitSearchBox ReadOnly
                      Underlined
                      ShowSearchButton
                      Style="width:80%"
                      Color="BitColor.Secondary"
                      @onclick="HandleOnSearchBoxClick" />

        <ProductsCarousel />
        <br />
        <ProductsSection />
        @*#endif*@

        @*#if (module != "Sales")*@
        <CascadingValue Value="BitDir.Ltr">
            <BitCard FullWidth Style="padding:2rem">
                <BitStack>
                    <BitText Typography="BitTypography.H5">Statistics</BitText>
                    <BitPivot Style="width:100%" Styles="@(new() { Body = "overflow:auto" })">
                        <BitPivotItem HeaderText="Nuget">
                            @if (isLoadingNuget)
                            {
                                <BitStack HorizontalAlign="BitAlignment.Center">
                                    <BitRippleLoading />
                                </BitStack>
                            }
                            else if (nugetStats is not null)
                            {
                                var data = nugetStats.Data[0];
                                <BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Package id:</BitText>
                                        <BitText><b>@data.Id</b></BitText>
                                    </BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Version:</BitText>
                                        <BitText><b>@data.Version</b></BitText>
                                    </BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Total downloads:</BitText>
                                        <BitText><b>@data.TotalDownloads.ToString("N0")</b></BitText>
                                    </BitStack>
                                </BitStack>
                            }
                            else
                            {
                                <BitText Typography="BitTypography.H4">Nuget stats could not be loaded.</BitText>
                            }
                        </BitPivotItem>
                        <BitPivotItem HeaderText="GitHub">
                            @if (isLoadingGitHub)
                            {
                                <BitStack HorizontalAlign="BitAlignment.Center">
                                    <BitRippleLoading />
                                </BitStack>
                            }
                            else if (gitHubStats is not null)
                            {
                                <BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Name:</BitText>
                                        <BitText><b>@gitHubStats.Name</b></BitText>
                                    </BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Total stars:</BitText>
                                        <BitText><b>@gitHubStats.StargazersCount.ToString("N0")</b></BitText>
                                    </BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Forks count:</BitText>
                                        <BitText><b>@gitHubStats.ForksCount.ToString("N0")</b></BitText>
                                    </BitStack>
                                    <BitStack Horizontal>
                                        <BitText>Repo:</BitText>
                                        @*-:cnd:noEmit*@
                                        <BitLink Target="_blank"
                                                 Href="https://github.com/bitfoundation/bitplatform/tree/develop/src/Templates/Boilerplate">
                                            <BitImage Alt="bitplatform GitHub stars"
                                                      Src="https://img.shields.io/github/stars/bitfoundation/bitplatform?style=social&label=Github%20%E2%9C%A8" />
                                        </BitLink>
                                        @*+:cnd:noEmit*@
                                    </BitStack>
                                </BitStack>
                            }
                            else
                            {
                                <BitText Typography="BitTypography.H4">GitHub stats could not be loaded.</BitText>
                            }
                        </BitPivotItem>
                    </BitPivot>
                </BitStack>
            </BitCard>
        </CascadingValue>
        <br />
        @*#endif*@

        <BitCard FullWidth Style="padding:4rem">
            <BitStack HorizontalAlign="BitAlignment.Center">
                <BitText Typography="BitTypography.H5">bit platform</BitText>
                <BitText Typography="BitTypography.Body1" Align="BitTextAlign.Center">@Localizer[nameof(AppStrings.BitPlatformMessage)]</BitText>
                <BitLink Href="https://bitplatform.dev" Target="_blank" NoUnderline>
                    <BitStack Horizontal VerticalAlign="BitAlignment.Baseline" Gap="0.5rem">
                        @Localizer[nameof(AppStrings.LearnMore)]
                        <BitIcon Size="BitSize.Small" IconName="@(CurrentDir is BitDir.Rtl ? BitIconName.ChromeBack : BitIconName.ChromeBackMirrored)" />
                    </BitStack>
                </BitLink>
                <BitLink Href="https://www.nuget.org/profiles/bit-foundation" Target="_blank" NoUnderline>
                    <BitImage Src="https://img.shields.io/badge/packages_download-8.2M-blue.svg?logo=nuget" Alt="nuget downloads" />
                </BitLink>
            </BitStack>
        </BitCard>

        <BitStack Horizontal Gap="2rem" Class="bit-products-stack">
            <BitCard Style="padding:3rem" FullWidth>
                <BitStack HorizontalAlign="BitAlignment.Center">
                    <BitText Typography="BitTypography.H5">bit BlazorUI</BitText>
                    <BitText Typography="BitTypography.Body1" Align="BitTextAlign.Center">
                        @Localizer[nameof(AppStrings.BitBlazorUIMessage)]
                    </BitText>
                    <BitButton Variant="BitVariant.Outline" Href="https://www.youtube.com/watch?v=ahgpbDAshmY" Target="_blank">
                        @Localizer[nameof(AppStrings.WatchVideo)]
                    </BitButton>
                    <BitLink Href="https://blazorui.bitplatform.dev/" Target="_blank" NoUnderline>
                        <BitStack Horizontal VerticalAlign="BitAlignment.Baseline" Gap="0.5rem">
                            @Localizer[nameof(AppStrings.LearnMore)]
                            <BitIcon Size="BitSize.Small" IconName="@(CurrentDir is BitDir.Rtl ? BitIconName.ChromeBack : BitIconName.ChromeBackMirrored)" />
                        </BitStack>
                    </BitLink>
                </BitStack>
            </BitCard>

            <BitCard Style="padding:3rem" FullWidth>
                <BitStack HorizontalAlign="BitAlignment.Center">
                    <BitText Typography="BitTypography.H5">bit project template</BitText>
                    <BitText Typography="BitTypography.Body1" Align="BitTextAlign.Center">
                        @Localizer[nameof(AppStrings.BitProjectTemplateMessage)]
                    </BitText>
                    <BitButton Variant="BitVariant.Outline" Href="https://www.youtube.com/watch?v=UjdWBvb0xac" Target="_blank">
                        @Localizer[nameof(AppStrings.WatchVideo)]
                    </BitButton>
                    <BitLink Href="https://bitplatform.dev/templates/overview/" Target="_blank" NoUnderline>
                        <BitStack Horizontal VerticalAlign="BitAlignment.Baseline" Gap="0.5rem">
                            @Localizer[nameof(AppStrings.LearnMore)]
                            <BitIcon Size="BitSize.Small" IconName="@(CurrentDir is BitDir.Rtl ? BitIconName.ChromeBack : BitIconName.ChromeBackMirrored)" />
                        </BitStack>
                    </BitLink>
                </BitStack>
            </BitCard>
        </BitStack>
    </BitStack>
</section>